# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=atkmm
pkgbase=mingw-w64-${_realname}-2.36
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-2.36"
pkgver=2.36.2
pkgrel=1
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}236")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}236")
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}236")
pkgdesc="C++ bindings for ATK (V2.36) (mingw-w64)"
url="https://www.gtkmm.org/"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
license=('spdx:LGPL-2.1-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-atk"
         "${MINGW_PACKAGE_PREFIX}-glibmm-2.68"
         "${MINGW_PACKAGE_PREFIX}-libsigc++-3.0")
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=('strip' '!debug' 'staticlibs')
source=("https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz")
sha256sums=('6f62dd99f746985e573605937577ccfc944368f606a71ca46342d70e1cdae079')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

}

build() {
  mkdir -p "build-${MSYSTEM}" && cd "build-${MSYSTEM}"

  declare -a _extra_config
  if check_option "debug" "n"; then
    _extra_config+=("--buildtype=release")
  else
    _extra_config+=("--buildtype=debug")
  fi

  CFLAGS+=" -Wno-attributes" \
  CXXFLAGS+=" -Wno-attributes" \
  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson.exe \
    --prefix="${MINGW_PREFIX}" \
    "${_extra_config[@]}" \
    --wrap-mode=nodownload \
    --default-library=both \
    --auto-features=enabled \
    -Dmaintainer-mode=false \
    -Dbuild-documentation=false \
    "../${_realname}-${pkgver}"

  ${MINGW_PREFIX}/bin/meson.exe compile
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/meson.exe test || true
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/meson.exe install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}-2.36/COPYING"
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.tools" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}-2.36/COPYING.tools"
}
